import requests
import re


THEurl = str(input("输入商品URL:"))
#测试例：
#THEurl="https://detail.tmall.com/item.htm?spm=a223ee.11136065.1936616854.2.162a51fcMx8nbJ&acm=lb-zebra-305313-6077340.1003.4.5528399&id=549481605917&scm=1003.4.lb-zebra-305313-6077340.ITEM_549481605917_5528399"

THEheaders = {
            "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Safari/537.36",
            "referer": "https://detail.tmall.com/item.htm?spm=a220m.1000858.1000725.8.12357de7uI1uOu&id=602977570356&skuId=4304210164437&areaId=510100&user_id=3351172141&cat_id=2&is_b=1&rn=d2044f57561b87fd83ad00ce338f0cd1&on_comment=1",
            "Cookie": "lid=%E8%B6%85%E5%A8%81%E8%93%9D%E7%8C%AB%E6%88%91%E6%9C%89%E7%9F%A5%E8%AF%86%E6%88%91%E8%87%AA%E8%B1%AA; enc=XJwcK4DybRwOk4R5bu%2FJtcXN2m4Kb5LngN9e7EDyoQu6UugNceB3rwsTxLri3HUWF6mWjfbvovS8HVZhYUcAHA%3D%3D; cna=IakcF4CQm3gCAXW7+dxgQxGp; sgcookie=E2lPAmrso4SdnP1qLE8a6; t=1f89b53da080fcee11386787b0604be1; tracknick=%5Cu8D85%5Cu5A01%5Cu84DD%5Cu732B%5Cu6211%5Cu6709%5Cu77E5%5Cu8BC6%5Cu6211%5Cu81EA%5Cu8C6A; lgc=%5Cu8D85%5Cu5A01%5Cu84DD%5Cu732B%5Cu6211%5Cu6709%5Cu77E5%5Cu8BC6%5Cu6211%5Cu81EA%5Cu8C6A; _tb_token_=318b35fe300eb; cookie2=1e4c25b69b94c9fe58758553009376f5; _m_h5_tk=ebb423f10f34ab8a0296615c7bb2662e_1587917103060; _m_h5_tk_enc=f7ee88a93e9cc1354e99a82f68a8055e; x5sec=7b22726174656d616e616765723b32223a223837333430666631343037653137653938396533306232363963666561346464434c61356c765546454d614f6d624f726d39486f3167453d227d; dnk=%5Cu8D85%5Cu5A01%5Cu84DD%5Cu732B%5Cu6211%5Cu6709%5Cu77E5%5Cu8BC6%5Cu6211%5Cu81EA%5Cu8C6A; uc1=existShop=false&cookie14=UoTUPcXJy2NZ6g%3D%3D&cookie15=UIHiLt3xD8xYTw%3D%3D&cookie21=VT5L2FSpccLuJBreK%2BBd&pas=0&cookie16=UIHiLt3xCS3yM2h4eKHS9lpEOw%3D%3D; uc3=nk2=0Jw4ZWKL5ncb%2BZbc%2BzeuWaIvSDzGqg%3D%3D&lg2=U%2BGCWk%2F75gdr5Q%3D%3D&id2=UU6kVzP5MUeA7w%3D%3D&vt3=F8dBxGRyNbP9gah03fE%3D; _l_g_=Ug%3D%3D; uc4=nk4=0%400hYwK0dP9pa%2BHtt%2BZ%2BnIIJJ3vuOLV1en5URtcwfplD3h&id4=0%40U2xpVauIQpog3DB9k9NdS5VHJyyf; unb=2654376244; cookie1=VW7p1uG6ehuQnGiMx3e1bs9aTbIAwbuKJpX8eqzeCcI%3D; login=true; cookie17=UU6kVzP5MUeA7w%3D%3D; _nk_=%5Cu8D85%5Cu5A01%5Cu84DD%5Cu732B%5Cu6211%5Cu6709%5Cu77E5%5Cu8BC6%5Cu6211%5Cu81EA%5Cu8C6A; sg=%E8%B1%AA42; csg=17e13678; l=eBSn_cgIQpsWV4I3BOfaFurza77OSIRYYuPzaNbMiT5P_WCW5_kOWZjSZW8XC31Vh6lyR3yAaP04BeYBqIq0x6aNa6Fy_Ckmn; isg=BD09weAUP_lJfZulrCdScNF0TJk32nEsVtiNIf-CeRTBNl1oxyqB_Avg4OpwrYnk"
        # 我自己的Cookie，用来绕过登陆框，可能会失效（目前倒是没遇到过）
        }


r=requests.get(THEurl,headers=THEheaders)
it = re.finditer(r'<li title="&nbsp;.*?">?(.*?)&nbsp;?(.*?)</li>',r.text )
for match in it:
    print(match.group(1)+re.sub('&nbsp','',match.group(2)))
